<template>
    <div>
        <ul class="mui-table-view">
            <li v-for="item in newsList" :key="item.id" class="mui-table-view-cell mui-media">
                <router-link :to="'/home/newsinfo/' + item.id">
                    <img class="mui-media-object mui-pull-left" :src="item.img_url">
                    <div class="mui-media-body">
                        {{item.title}}
                        <p class='mui-ellipsis'>
                            <span>发表时间:{{item.add_time | dtFormat}}</span>
                            <span>点击:{{item.click}}次</span>
                        </p>
                    </div>
                </router-link>
            </li>
		</ul>
    </div>
</template>

<script>
export default {
  data() {
    return {
      newsList: []
    };
  },
  created() {
    this.getNewsList();
  },
  methods: {
    async getNewsList() {
      const { data: res } = await this.$http.get("/api/getnewslist");
      if (res.status != 0) return Toast("获取图文信息失败！");
      this.newsList = res.message;
    }
  },
  // filters:{
  //   dtFormat(originVal){
  //      const date = new Date(originVal) 
  //         const y = date.getFullYear()
  //         const M = (date.getMonth() + 1).toString().padStart(2,'0');
  //         const d = date.getDate().toString().padStart(2,'0');
  //         const H = date.getHours().toString().padStart(2,'0');
  //         const m = date.getMinutes().toString().padStart(2,'0');
  //         const s = date.getSeconds().toString().padStart(2,'0');
  //         return `${y}-${M}-${d} ${H}:${m}:${s}`
  //   }
  // }
};
</script>

<style lang="scss" scoped>
.mui-table-view {
  li {
    h1 {
      font-size: 14px;
    }
    .mui-ellipsis {
      font-size: 12px;
      color: #0094ff;
      display: flex;
      justify-content: space-between;
    }
  }
}
</style>

